<?php
// vim: set expandtab tabstop=2 shiftwidth=2:

/**
 *	php Object Oriented HTML API (pOHA) [poo-HA]
 *
 *	"Improvement makes straight roads: but the crooked roads without 
 *	improvement are roads of Genius."
 *
 *	Developed in conjunction with ComPort, and handles output through
 *	a hierarchy of arrays that are interpreted by pOHA. This means a complete separation
 *	of markup and code and allows pOHA to handle the rendering of various
 *	document types (PDF, WML, XHTML etc).
 *	
 *	pOHA was originally geared specifically for the Web. Ideally it should
 *	give coders, who are not necessarily proficient in front-end scripting,
 *	access to a library of sophisticated GUI enhancements which 
 *	'massage' the HTML output page as a whole. It allows JavaScript nerds to
 *	encapsulate their wonders in an interface that everyone can reuse
 *	seamlessly without any JavaScript knowledge at all.
 *	
 *	After doing some intense scripting of this type, making a series of
 *	stand alone GUI enhancements I wanted a way I could easily reuses the
 *	code quickly without having to dig up some cryptic code sprayed across a
 *	page (as JavaScript often forces you to do) and try and remember how to
 *	reapply it. So now anything I do on the front-end will always be easy
 *	to reuses again and allow other developers to uses these code snippets
 *	and developed for the API independently.
 *	
 *	Hopefully this will help move web development to the next level, where
 *	we don't spend all our time worrying about browser compatibility or
 *	writing code that we spend hours tiring to reuses, and we can just think
 *	about higher level problems (like what's for lunch).
 *
 *	@version	2.0
 *	@author 	Alexander R B Whillas BSCS <dev@tsd.net.au>
 *	@package	pOHA
 */

if(!function_exists('is_a'))
	include('is_a.php');

/*
 * 04/07/10
 *
 * From: http://php.net/manual/en/function.empty.php
 * "0" must not be empty
 *
 * Edited by Dax
 */

/**
 *	Specifies that the rendering of pOHA objects is to conform to the HTML 3.2 standard.
 *
 *	@var integer
 *	@see Element::render()
 */
define("POHA_HTML_3_2", 1);

/**
 *	Specifies that the rendering of pOHA objects is to conform to the XHTML standard.
 *
 *	@var integer
 *	@see Element::render()
 */
define("POHA_XHTML", 2);

/**
 *	Specifies that the rendering of pOHA objects is to conform to the HTML 4 standard.
 *
 *	@var integer
 *	@see Element::render()
 */
define("POHA_HTML_4", 2);

/**
 *	Specifies that the rendering of pOHA objects is to conform to the XML 1.0 standard.
 *
 *	@var integer
 *	@see Element::render()
 */
define("POHA_XML_1", 3);

/**
 *	Specifies that the rendering of pOHA objects is to conform to the SVG 1.0 standard.
 *
 *	@var integer
 *	@see Element::render()
 */
define("POHA_SVG_1", 4);

/**
 * 	Block-like elements e.g. paragraphs and lists.
 *
 *	Specifies that the tags for a pOHA object are to be rendered as block tags (i.e. there
 *	is a start and end tag specifying the block for the tag).
 *
 *	This is implicitly determined in the {@link Element::Element() constructor}
 *	for {@link Element}.
 *
 *	@var	integer
 *	@see	Element::render()
 */
define("POHA_BLOCK", 0);

/**
 *	Character level elements and text strings
 * 
 *	Specifies that the tags for a pOHA object are to be rendered as an inline tag
 *	(i.e. there is only one tag <.. />).
 *
 *	This is implicitly determined in the {@link Element::Element() constructor}
 *	for {@link Element}.
 *
 *	@var integer
 *	@see Element::render()
 */
define("POHA_INLINE", 1);

/**
 *	Specifies that a {@link ItemList HTML list} is to be rendered as an ordered list.
 *
 *	@var integer
 */
define("POHA_ORDERED_LIST", 0);

/**
 *	Specifies that a {@link ItemList HTML list} is to be rendered as an unordered list.
 *
 *	@var integer
 */
define("POHA_UNORDERED_LIST", 1);

/**
 *	Postfix for the name of the input field used to specify a file to upload.
 *
 *	This is added to the name of the input field so that it's name does not conflict
 *	with the input field that lists the files that already exist on the server.
 *
 *	@var string POHA_FILE_UPLOAD_EXT
 *	@see FilePickerInput::FilePickerInput()
 */
define("POHA_FILE_UPLOAD_EXT", "_fileUpload");


/**
 *	Represents a HTML document that is to be rendered.
 *
 *	Conceptually, this class represents a HTML document that consists
 *	of HTML tags and content. Each of the HTML tags and content that finds
 *	itself in the body of this page is represented by a {@link Element pOHA object}.
 *	Therefore, this class can be thought of as a container that manages the
 *	{@link Element pOHA objects} to be rendered in its body.
 *
 *	Controlling the rendering process is an important function of this class and is
 *	largely the responsibility of the {@link HTMLPage::render()} function.
 *
 *	@todo		Make the standards conformance work (needs to also place the correct <!DOCTYPE... at the top of the page.
 *	@todo		Rewrite using more of the Element classes functions, perhaps inherit it? YES make it a Element object.
 *	@package	pOHA
 */
class Page
{
	/**
	 *	An array of {@link Element pOHA objects} that make up the body/content of this {@link HTMLPage}.
	 *
	 *	@var array $_content
	 *	@access protected
	 *	@see add()
	 */
	var $_content;
	
	/**
	 *	Defines the standard to which the rendering of this {@link HTMLPage} is
	 *	to confirm to.
	 *
	 *	The idea behind this member is that a browser detection script
	 *	might determine what the browser is capable of and then degrade
	 *	the standards conformance to render a page it can read. Perhaps going
	 *	so far as to render text only without markup.
	 *
	 *	At the moment the API only caters to HTML 4.0 (which conforms to HTML 3.2 and XML 1.0)
	 *	so no bones broken. This is more for future imlpentations
	 *	and will probably be discared in favour of XSLT.
	 *
	 *	@var string
	 *	@access	protected
	 *	@see Page()
	 *	@see render()
	 */
	var $_standard;
	
	function Page($content = array(), $standard = POHA_HTML_4)
	{
		$this->_content = $content;
		$this->_standard = $standard;
	}
	
	/**
	 *	Adds content to this {@link HTMLPage} to be rendered.
	 *
	 *	The content added is rendered between the <body> tags of the generated HTML document for this
	 *	{@link HTMLPage}.
	 *
	 *	@param mixed $content_object Must either be a string (either HTML or plain text) or a
	 *		{@link Element pOHA object}.
	 *	@access public
	 */
	function add($content)
	{
		if(is_array($content))
			$this->_content = array_merge($this->_content, $content);
		else
			$this->_content[] = $content;
	}
	
	function render($standard = '')
	{
		return '';
	}
}

/**
 *	@version	2.0
 *	@author 	Alexander R B Whillas BSCS <dev@tsd.net.au>
 *	@package	pOHA
 */
class HTMLPage extends Page
{
        var $_head;

	/**
	 *	The title of this {@link HTMLPage}.
	 *
	 *	The title is usually shown in the title bar of browser windows.
	 *
	 *	@var string $_title
	 *	@access	protected
	 *	@see Page()
	 */
	var $_title;
	
	/**
	 *	A language code indicating the language of the content 
	 *	being displayed.
	 *
	 *	[RFC1766] defines and explains the language codes that must be used in HTML documents.
	 *	Two-letter primary codes are reserved for [ISO639] 
	 *	language abbreviations.
	 *
	 *	@var string $_language
	 *	@access	protected
	 *	@see Page()
	 */	
	var $_language;
	
	/**
	 *	An array of CSS file names to be referenced by this {@link HTMLPage}.
	 *
	 *	The filenames can be supplied as relative or absolute paths.
	 *
	 *	@todo Write an accessor function for this member.
	 *	@todo Make it possible to assign CSS files for specific browsers (user agent matching).
	 *	@var string $_cssFileName
	 *	@access	private
	 */
	var $_css_list;
	
	/**
	 *	JavaScript code that is to be included in this {@link HTMLPage}.
	 *
	 *	The contents of this member get rendered between <script> tags.
	 *
	 *	@var string $javaScriptHeader
	 *	@access	public
	 */
	var $javascript_header;
	
	/**
	 *	An associative array of HTML meta-data attributes to be rendered for this {@link HTMLPage}.
	 *
	 *	The index to the array is the name of the attribute and the element it refers to the the attribute's
	 *	value.
	 *
	 *	@todo Write an accessor function for this member.
	 *	@var array $metaData
	 *	@access protected
	 */
	var $_meta_data;
	
	/**
	 *	An array of JavaScript libraries to be included in this {@link HTMLPage}.
	 *
	 *	@todo Write an accessor function for this member.
	 *	@var array $_javascriptIncludes
	 *	@access protected
	 */
	var $_javascript_includes;

	/**
	 *	Default constructor.
	 *
	 *	This constructor initialises this {@link HTMLPage} based on the supplied arguments.
	 *
	 *	@param	string	Title of the page.
	 *	@param	string	Path/File name to the CSS file to be linked to in the header of the page. Defaults to nothing.
	 *	@param	string	ISO639 language code to be used.
	 *	@param	integer	Specifies the standard that the {@link render() rendering()} this {@link HTMLPage} will conform to. Valid values are: {@link POHA_HTML_4} or {@link POHA_HTML_3_2}.
	 *	@access	public
	 */
	function HTMLPage($title = '', $css_list = NULL, $language = 'en', $standard = POHA_HTML_4)
	{
		parent::Page(array(), $standard);
		
		$this->_title = $title;
		$this->_language = $language;
		
		if(!is_null($css_list))
		{
			if(is_array($css_list))
				$this->_css_list = $css_list;
			else
				$this->_css_list[] = $css_list;
		}
		else
			$this->_cssList = array();
		
		//$this->_meta_data = array('generator' => 'pOHA: php Object Oriented HTML API');
		$this->_javascript_includes = array();
		$this->javascript_header = '';
	}

        function addHead($head)
        {
            $this->_head .= $head;
        }
	
	/**
	 * Adds a metadata name/content pair to the pages header.
	 *
	 * @access	public
	 * @param	Array	An associative array with the key as the name and the value as the content parts
	 * @return	boolean	True if succesful, false on error.
	 */
	function addMetaData ($p_meta_data)
	{		
		if(is_array($p_meta_data))
		{
			foreach($p_meta_data as $key => $value)
				$this->_meta_data[$key] = $value;
			
			return true;
		}
		else
			return false;
	}
	
	/**
	 *	Generates all the HTML between the <head></head> tags of this {@link HTMLPage}.
	 *
	 *	@param integer $standard	If it exists, it overrides this {@link HTMLPage}'s configured {@link
	 *		_standard standards conformance} setting.
	 *	@return string The contents of the <head> tag for this {@link HTMLPage}.
	 *	@access protected
	 */
	function _renderHead($standard = POHA_HTML_4)
	{
		$out = "<head>\n\t<title>$this->_title</title>\n";

                if(!empty($this->_head))
                {
                    $out .= "$this->_head\n";
                }
		
		if(!empty($this->_css_list))
		{
			foreach ($this->_css_list as $file_name)
				$out .=  "\t<link href=\"$file_name\" type=\"text/css\" rel=\"stylesheet\" />\n";
		}
			
		if(!empty($this->_meta_data))
		{
			foreach ($this->_meta_data as $name => $content)
				$out .=  "\t<meta name=\"$name\" content=\"$content\" lang=\"$this->_language\" />\n";
		}
		
		if(!empty($this->_javascript_includes))
		{
                    print_r($this->_javascript_includes);

			foreach ($this->javascript_includes as $file_name)
				$out .=  "\t<script src=\"$file_name\" language=\"JavaScript\" type=\"text/javascript\"></script>\n";
		}
			
		if(!empty($this->javascript_header))
			$out .=  "\t<script language=\"JavaScript\">\n$this->javascript_header\n\t</script>\n";
		
		$out .=  "</head>\n";
		
		return $out;
	}
	
	/**
	 *	Generates all the HTML between the <body></body> tags of this {@link HTMLPage}.
	 *
	 *	This method, essentially, creates a new {@link Element pOHA object} for the body tags
	 *	and passes the {@link _contents contents} of this {@link HTMLPage} as the contents of the new
	 *	{@link Element pOHA object} for the body tag.
	 *
	 *	@param integer $standard If it exists, it overrides this {@link HTMLPage}'s configured {@link
	 *		_standard standards conformance} setting.
	 *	@return string The contents of the <head> tag for this {@link HTMLPage}.
	 *	@access protected
	 */	
	function _renderBody($standard = POHA_HTML_4)
	{
		$body = new Element('body', NULL, $this->_content);
		return $body->render($standard);
	}
	
	/**
	 *	Generates the HTML document for this {@link HTMLPage}.
	 *
	 *	This method renders the document in its entireity.
	 *
	 *	@param integer $p_standards_conformance	If it exists, it overrides this {@link HTMLPage}'s configured {@link
	 *		_standard standards conformance} setting.
	 *	@return string The generated document.
	 *	@access public
	 *	@see _renderHead()
	 *	@see _renderBody()
	 */
	function render($standard = '')
	{
		if(empty($standard))
			$standard = $this->_standard;
			
		if($standard == POHA_HTML_4)
		{
                        $out = "<!DOCTYPE html PUBLIC \"-//W3C//DTD XHTML 1.0 Transitional//EN\" \"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd\">\n";
			$out .= "<html xmlns=\"http://www.w3.org/1999/xhtml\">\n";
			$out .= $this->_renderHead($standard);
			$out .= $this->_renderBody($standard);
			$out .= "</html>\n";
		}
		
		return $out;
	}
}




/**
 *	The base pOHA object that represents any possible HTML content.
 *
 *	This class is flexible enough to be able to represent any HTML compliant tag and it's content.
 *	It has the ability to nest other tags (as pOHA objects).
 *
 *	The main function of this class is to allow the developer to create a pOHA object,
 *	configure it according to the tag they wish to add to a {@link HTMLPage} or other pOHA object
 *	and then to evetually render the tag and contents that this pOHA object represents
 *	(including any nested pOHA objects).
 *
 *	This class can be used as a base class for defining more specific pOHA objects (document elements).
 *
 *	@version 1
 *	@author Alexander R B Whillas BSCS <dev@tsd.net.au>
 *	@package pOHA
 */
class Element
{
	/**
	 *	The value of the tag itself.
	 *
	 *	e.g. "body" for <body></body> tags.
	 *
	 *	@var string $_tag
	 *	@access protected
	 *	@see render()
	 */
	var $_tag;
	
	/**
	 *	Indicates what type of a tag this is.
	 *
	 *	A tag, currently, can be an {@link POHA_INLINE inline} or {@link POHA_BLOCK block}
	 *	block tag.
	 *
	 *	@var integer $_tag_type
	 *	@access protected
	 *	@see render()
	 */	
	var $_tag_type;
	
	/**
	 *	An array containing the contents to be rendered for this tag.
	 *
	 *	This array can contain a mixture of text (plain or HTML) and/or other {@link
	 *	Element pOHA objects}.
	 *
	 *	@var array $_content
	 *	@access protected
	 *	@see render()
	 */
	var $_content;

	/**
	 *	An associative array of attributes that are to be rendered for this tag.
	 *
	 *	The index of this tag is the name of the attribute and the element it refers to is the
	 *	value of that attribute.
	 *
	 *	@var array $_attributes
	 *	@access protected
	 *	@see render()
	 */
	var $_attributes;
	
	/**
	 *	Determines whether indentation of the contents of this {@link Element pOHA object}
	 *	are included when they are rendered.
	 *
	 *	This option affects only {@link POHA_BLOCK block} {@link $_tag_type type} tags.
	 *
	 *	If this member is set to TRUE, then no indendation is rendered for the contents.
	 *
	 *	@var boolean
	 */
	var $_no_white_space = FALSE;

	/**
	 * Default constructor.
	 *
	 * This constructor initialises this {@link Element pOHA object} based on the supplied arguments.
	 *
	 * @param	string	$tag The value of the {@link $_tag tag} name.
	 * @param	string	$attributes	An associative array of {@link $_attributes attributes} of this tag.
	 * @param	mixed	$content The content of this {@link Element pOHA object}. This argument can be either text (plain or HTML), a {@link Element pOHA object}, an array of text and/or {@link Element pOHA objects} or nothing.
	 * @access	public
	 */
	function Element($tag, $attributes = NULL, $content = NULL)
	{
		$this->_tag = $tag;
		$this->_attributes = $attributes;
		
		if(is_null($content))
			$this->_tag_type = POHA_INLINE;
		else
		{
			if(is_array($content))
				$this->_content = $content;
			else 
				$this->_content = array($content);		
			
			$this->_tag_type = POHA_BLOCK;
		}
	}
	
	/**
	 *	Adds content to this {@link Element pOHA object} to be rendered.
	 *
	 *	The content added is {@link render() rendered} between the tags generated by this {@link
	 *	Element pOHA object}.
	 *
	 *	@param mixed $content Must either be a string (either HTML or plain text) or a {@link Element
	 *		pOHA object}.
	 *	@access public
	 */
	function add($content)
	{
		if(is_array($content))
			$this->_content = array_merge($this->_content, $content);
		else
			$this->_content[] = $content;
	}
	
	/**
	 *	Generates the HTML for this {@link Element pOHA object}.
	 *
	 *	This method renders this {@link Element pOHA object} as well as it's contents.
	 *
	 *	This method simply delegates the rendering of this {@link Element pOHA object} depending on its
	 *	{@link $_tag_type type}.
	 *
	 *	@param integer $standard The standard to which the rendering of this {@link Element
	 *		pOHA object} is to conform to.
	 *	@param integer $tabLevel The level of indentation at which this {@link Element pOHA object} is to
	 *		be rendered.
	 *	@return string The generated HTML.
	 *	@access public
	 *	@see _renderAsInlineElement()
	 *	@see _renderAsBlockElement()
	 */
	function render($standard = POHA_HTML_4, $tabLevel = 0)
	{
		switch($this->_tag_type)
		{
			case POHA_INLINE:
				return $this->_renderAsInlineElement($standard, $tabLevel);
				break;
			default:
				return $this->_renderAsBlockElement($standard, $tabLevel);
		}
	}
	
	/**
	 * Get the value of the given attribute.
	 *
	 * @param	string	The name of the attribute.
	 * @return	mixed	The value of the attribute, FALSE if it doesn't exist.
	 * @access	public
	 */
	function getAttribute($attribute_name)
	{
		if(isset($this->_attributes[$attribute_name]))
			return $this->_attributes[$attribute_name];
		else
			return FALSE;
	}
	
	/**
	 * Set the value of the given attribute.
	 *
	 * @param	string	The name of the attribute.
	 * @param	mixed	The value to set the attribute to.
	 * @access	public
	 */
	function setAttribute($attribute_name, $value)
	{
		$this->_attributes[$attribute_name] = $value;
	}	
	
	/**
	 *	Renders this {@link Element pOHA object} as a block element.
	 *
	 *	This method delegates the rendering of this pOHA object based on its {@link $_noWhiteSpace whitespace
	 *	setting}.
	 *
	 *	@param integer $standard The standard to which the rendering of this {@link Element
	 *		pOHA object} is to conform to.
	 *	@param integer $tabLevel The level of indentation at which this {@link Element pOHA object} is to
	 *		be rendered.
	 *	@return string The generated HTML.
	 *	@access protected
	 *	@see _renderBlockElementNoWhiteSpace()
	 *	@see _renderBlockElement()
	 */
	function _renderAsBlockElement($standard = POHA_HTML_4, $tab_level = 0)
	{
		if ($this->_noWhiteSpace)
			return $this->_renderBlockElementNoWhiteSpace($this->_tag, $this->_content, $this->_attributes, $standard, $tab_level);
		else
			return $this->_renderBlockElement($this->_tag, $this->_content, $this->_attributes, $standard, $tab_level);
	}
	
	/**
	 *	Renders this {@link Element pOHA object} as a block element with no white spaces.
	 *
	 *	This renderer simply leaves no whitespaces between the start tag, end tag and the content between them.
	 *
	 *	@param string $tag The value of the {@link $_tag tag} name.
	 *	@param mixed $content The content of this {@link Element pOHA object}. This argument can be either
	 *		text (plain or HTML), a {@link Element pOHA object}, an array of text and/or {@link
	 *		Element pOHA objects} or nothing.
	 *	@param string $attributes An associative array of {@link $_attributes attributes} of this tag.
	 *	@param integer $standard The standard to which the rendering of this {@link Element
	 *		pOHA object} is to conform to.
	 *	@param integer $tabLevel The level of indentation at which this {@link Element pOHA object} is to
	 *		be rendered.
	 *	@return string The generated HTML.
	 *	@access protected
	 *	@see _renderAttributes()
	 *	@see _processContent()
	 */
	function _renderBlockElementNoWhiteSpace($tag, $content, $attributes = '', $standard = POHA_HTML_4, $tab_level = 0)
	{
		$tab = str_repeat("\t", $tab_level);
		
		$out = $tab."<" . $tag . $this->_renderAttributes($attributes) . ">";
		$out .= trim($this->_processContent($content, $standard, $tab_level++));
		$out .= "</" . $tag . ">\n";
		return $out;
	}
	
	/**
	 *	Renders this {@link Element pOHA object} as a block element.
	 *
	 *	@param string $tag The value of the {@link $_tag tag} name.
	 *	@param mixed $content The content of this {@link Element pOHA object}. This argument can be either
	 *		text (plain or HTML), a {@link Element pOHA object}, an array of text and/or {@link
	 *		Element pOHA objects} or nothing.
	 *	@param string $attributes An associative array of {@link $_attributes attributes} of this tag.
	 *	@param integer $standard The standard to which the rendering of this {@link Element
	 *		pOHA object} is to conform to.
	 *	@param integer $tabLevel The level of indentation at which this {@link Element pOHA object} is to
	 *		be rendered.
	 *	@return string The generated HTML.
	 *	@access protected
	 *	@see _renderAttributes()
	 *	@see _processContent()
	 */
	function _renderBlockElement($tag, $content, $attributes = '', $standard = POHA_HTML_4, $tab_level = 0)
	{
		$tab = str_repeat("\t", $tabLevel);
		
		$out = $tab."<" . $tag . $this->_renderAttributes($attributes) . ">\n";
		$out .= $this->_processContent($content, $standard, $tab_level++);
		$out .= $tab."</" . $tag . ">\n";
		
		return $out;
	}
	
	/**
	 *	Renders this {@link Element pOHA object} as an inline element.
	 *
	 *	The actual rendering is delegated to {@link _renderInlineElement()}
	 *
	 *	@param integer $standard The standard to which the rendering of this {@link Element
	 *		pOHA object} is to conform to.
	 *	@param integer $tabLevel The level of indentation at which this {@link Element pOHA object} is to
	 *		be rendered.
	 *	@return string The generated HTML.
	 *	@access protected
	 *	@see _renderInlineElement()
	 */
	function _renderAsInlineElement($standard = POHA_HTML_4, $tab_level = 0)
	{
		return $this->_renderInlineElement($this->_tag, $this->_attributes, $standard, $tab_level);
	}
	
	/**
	 *	Renders this {@link Element pOHA object} as an inline element.
	 *
	 *	@param string $tag The value of the {@link $_tag tag} name.
	 *	@param string $attributes	An associative array of {@link $_attributes attributes} of this tag.
	 *	@param integer $standard The standard to which the rendering of this {@link Element
	 *		pOHA object} is to conform to.
	 *	@param integer $tabLevel The level of indentation at which this {@link Element pOHA object} is to
	 *		be rendered.
	 *	@return string The generated HTML.
	 *	@access protected
	 *	@see _renderBlockElementNoWhiteSpace()
	 *	@see _renderBlockElement()
	 */
	function _renderInlineElement($tag, $attributes, $standard = POHA_HTML_4, $tab_level = 0)
	{
		$tab = str_repeat("\t", $tab_level);	
		
		return $tab."<" . $tag . $this->_renderAttributes($attributes) . " />\n";
	}
	
	/**
	 *	Renders the attributes for this {@link Element pOHA object}.
	 *
	 *	Attributes are rendered as name-value pairs that are located within the tag element
	 *	of this pOHA object.
	 *
	 *	The rendering of a single attribute is delegated to {@link _renderAttribute()}.
	 *
	 *	@param array $attributes An associative array of the attributes to render. The index is the name of the attribute and the element
	 *		the index refers to is the attribute's value.
	 *	@return string The attribute portion of the tag of this pOHA object.
	 *	@access protected
	 */
	function _renderAttributes($attributes)
	{
		$out = '';

		if(!is_null($attributes) and is_array($attributes))
                {
                    foreach($attributes as $name => $value)
                    {
                        /*
                         *  04-07-2010
                         *
                         * Aggiunto:
                         *   is_string($value) && $value != ''
                         * per controllare "0" (deve essere considerato valido, non vuoto)
                         */
                        if(!empty($value) || is_string($value) && $value != '')
                        {
                            $out .= $this->_renderAttribute($name, $value);
                        }
                    }
		}
			
		return $out;
	}
	
	/**
	 *	Generates the string for a tag attribute.
	 *
	 *	This method generates a string which contains the supplied attribute name and value
	 *	in the standard XML/HTML name value pair format.
	 *
	 *	@param string $name The name of the attribute to render.
	 *	@param string $value The value of the attribute to render.
	 *	@return string The rendered attribute string.
	 *	@access protected
	 */
	function _renderAttribute($name, $value)
	{
		return " $name=\"$value\"";
	}
	
	/**
	 *	Recursively processes the content of this {@link Element pOHA object}.
	 *
	 *	The logic of this method is quite simple: for al the content supplied
	 *	it attempts to appropriately render it nested within the the tags of this pOHA
	 *	object. The tabs for each nested piece of content (text/HTML or another pOHA object)
	 *	are also calculated based on its level of nesting.
	 *
	 *	Text/HTML content is simply rendered as is. pOHA objects are called upon to {@link
	 *	render() render themselves}.
	 *
	 *	@param array $content An array of the nested content to render.
	 *	@param integer $standard The standard to which the rendering of this {@link Element
	 *		pOHA object} is to conform to.
	 *	@param integer $tabLevel The level of indentation at which this {@link Element pOHA object} is to
	 *		be rendered.
	 *	@return string The rendered contents of this pOHA object.
	 *	@access protected
	 */
	function _processContent($content, $standard, $tab_level = 0)
	{
		$output = '';
		
		$tab = str_repeat("\t", $tab_level);
		$tabLevel++;
		if(!empty($content) and is_array($content))
		{
			foreach($content as $item)
			{
				if (!empty($item))
					if (is_string($item))
						if ($this->_noWhiteSpace)
							$output .= $item;
						else
							$output .= $tab."\t".$item."\n";
					else if (is_a($item, "Element"))
						$output .= $item->render($standard, $tab_level);
					else if (is_array($item))
						$output .= $this->_processContent($item, $standard, $tab_level);
			}
		}
		
		return $output;
	}
}



/**
 *	A {@link Element pOHA object} that represents a HTML heading tag element.
 *
 *	This class is a specialised pOHA object that renders heading tags.
 *
 *	@version 1
 *	@author Alexander R B Whillas BSCS <dev@tsd.net.au>
 *	@package pOHA
 */
class HTMLHeading extends Element
{
	/**
	 *	The heading level of this heading pOHA object.
	 *
	 *	@var integer $_level
	 *	@access protected
	 */
	var $_level;
	
	/**
	 *	Default constructor.
	 *
	 *	This constructor assigns the supplied heading level to this {@link Heading heading pOHA object}
	 *	and then calls upon the parent constructor to set up the basic pOHA object settings specifically
	 *	for this element.
	 *
	 *	@param	mixed	The content of this {@link Element pOHA object}. This argument can be either text (plain or HTML), a {@link Element pOHA object}, an array of text and/or {@link Element pOHA objects} or nothing.
	 *	@param	integer	The heading level for this heading pOHA object. Integer between 1 and 6.
	 *	@param	string	The value of the class attribute to assign to this heading pOHA object.
	 *	@param	string	The value of the id attribute to assign to this heading pOHA object.
	 *	@access	public
	 */
	function HTMLHeading ($content, $level = 1, $class = '', $id = '')
	{
		if (is_numeric($level) and $level > 0 and $level <= 6)
			$this->_level = $level;
		else
		{
			trigger_error('[HTMLHeading::HTMLHeading()] : Bad heading level: '.$level, E_USER_NOTICE);
			$level = 1;
		}
		parent::Element('h'.$level, array('class' => $class, 'id' => $id), $content);
	}
	
	/**
	 *	Accessor function to set the heading level of this {@link Heading heading pOHA object}.
	 *
	 *	@param integer $level The heading level to assign to this heading pOHA object.
	 *	@access public
	 *	@see _level
	 */
	function setLevel($level)
	{
		if(is_integer($level))
		{
			$this->_level = $level;
			$this->_tag = 'h'.$level;
		}
	}
	
	/**
	 *	Accessor function that gets the current heading level for this {@link Heading heading pOHA object}.
	 *
	 *	@return integer The current heading level.
	 *	@access public
	 */
	function getLevel()
	{
		return $this->_level;
	}
}


/**
 * A {@link Element pOHA object} that represents a HTML hyperlink tag element.
 *
 * This class is a specialised pOHA object that renders hyperlink <a></a> tags.
 *
 * @version	1
 * @author 	Alexander R B Whillas BSCS <dev@tsd.net.au>
 * @package	pOHA
 */
class HTMLAnchor extends Element
{
	/**
	 *	Default constructor.
	 *
	 *	This constructor calls upon the parent constructor to set up the basic pOHA object settings specifically
	 *	for this element.
	 *
	 *	@param	string	The URL of the hyperlink to render.
	 *	@param	mixed	The content of this hyperlink pOHA object is the text value of the hyperlink to render.
	 *		This argument can be either text (plain or HTML), a {@link Element pOHA object},
	 *		an array of text and/or {@link Element pOHA objects} or nothing.
	 *	@param	string	The target of the hyperlink to render.
	 *	@param	string	The value of the name attribute for this anchor.
	 *	@param	string	The value of the class attribute to assign to this heading pOHA object.
	 *	@param	string	The value of the id attribute to assign to this heading pOHA object.
	 *	@access	public
	 */
	function HTMLAnchor($url, $content = '', $target = '', $name = '', $class = '', $id = '')
	{
		$attributes = array(	'href'		=> $url,
								'target' 	=> $target,
								'name'		=> $name,
								'class'		=> $class,
								'id'		=> $id
							);
		parent::Element('a', $attributes, $content);
	}
}


/**
 * HTML bookmarks an anchor tag with only a name.
 *
 * @version	1.0
 * @author	Bernard Leckning <bernard@dorja.com>
 * @package	pOHA
 */
class HTMLBookmark extends HTMLAnchor
{
	function HTMLBookmark($name, $content = '')
	{
		parent::HTMLAnchor('', $content, '', $name);
		$this->_tag_type = POHA_BLOCK;	// no matter what, this should never get rendered inline!
	}
}


/**
 *	A {@link Element pOHA object} that represents a HTML paragraph tag element.
 *
 *	This class is a specialised pOHA object that renders paragraph <p></p> tags.
 *
 *	@version	1.1
 *	@author		Alexander R B Whillas BSCS <dev@tsd.net.au>
 *	@package	pOHA
 */
class HTMLParagraph extends Element {
	/**
	 *	Default constructor.
	 *
	 *	This constructor calls upon the parent constructor to set up the basic pOHA object settings specifically
	 *	for this element.
	 *
	 *	@param mixed $content The content to be rendered between the <p></p> tags.
	 *		This argument can be either text (plain or HTML), a {@link Element pOHA object},
	 *		an array of text and/or {@link Element pOHA objects} or nothing.
	 *	@param string $class The value of the class attribute to assign to this heading pOHA object.
	 *	@param string $id The value of the id attribute to assign to this heading pOHA object.
	 *	@access public
	 */
	function HTMLParagraph($content, $class = '', $id = '')
	{
		parent::Element('p', array('class' => $class, 'id' => $id), $content);
	}
}


/**
 *	A {@link Element pOHA object} that represents a HTML block.
 *
 *	This class renders a generic block of HTML content into either <span></span> or <div></div>
 *	tags.
 *
 *	@version  1
 *	@author	Alexander R B Whillas BSCS <dev@tsd.net.au>
 *	@package pOHA
 */
class HTMLBlock extends Element
{
	/**
	 *	Default constructor.
	 *
	 *	This constructor calls upon the parent constructor to set up the basic pOHA object settings specifically
	 *	for this element.
	 *
	 *	@param mixed $content The content to be rendered between the tags.
	 *		This argument can be either text (plain or HTML), a {@link Element pOHA object},
	 *		an array of text and/or {@link Element pOHA objects} or nothing.
	 *	@param string $class The value of the class attribute to assign to this heading pOHA object.
	 *	@param string $id The value of the id attribute to assign to this heading pOHA object.
	 *	@param boolean $paragraphed If TRUE, then this block will be rendered as a div and if FALSE, it will be
	 *		rendered as a span.
	 *	@access public
	 */
	function HTMLBlock($content, $class = '', $id = '', $paragraphed = TRUE)
	{
		if($paragraphed) 
			$tag = 'div'; 
		else 
			$tag = 'span';
			
		parent::Element($tag, array('class' => $class, 'id' => $id), $content);
	}
}

/**
 *	A {@link Element pOHA object} that represents a HTML span tag element.
 *
 *	This class is a specialised pOHA object that renders span <span></span> tags.
 *
 *	@version 1
 *	@author Alexander R B Whillas BSCS <dev@tsd.net.au>
 *	@package pOHA
 */
class HTMLSpan extends Element
{
	/**
	 *	Default constructor.
	 *
	 *	This constructor calls upon the parent constructor to set up the basic pOHA object settings specifically
	 *	for this element.
	 *
	 *	This includes making sure that no {@link Element::_noWhiteSpace white spaces} are rendered in the
	 *	content.
	 *
	 *	@param mixed $content The content to be rendered between the <span></span> tags.
	 *		This argument can be either text (plain or HTML), a {@link Element pOHA object},
	 *		an array of text and/or {@link Element pOHA objects} or nothing.
	 *	@param string $class The value of the class attribute to assign to this heading pOHA object.
	 *	@param string $id The value of the id attribute to assign to this heading pOHA object.
	 *		rendered as a span.
	 *	@access public
	 */
	function HTMLSpan($content, $class = '', $id = '') {
		parent::Element('span', array('class' => $class, 'id' => $id), $content);
		$this->_no_white_space = TRUE;
	}
}


/**
 *	A {@link Element pOHA object} that represents a HTML image tag element.
 *
 *	This class is a specialised pOHA object that renders an <image /> tag.
 *
 *	@version 1
 *	@author Alexander R B Whillas BSCS <dev@tsd.net.au>
 *	@package pOHA
 */
class HTMLImage extends Element
{
	/**
	 *	Default constructor.
	 *
	 *	This constructor calls upon the parent constructor to set up the basic pOHA object settings specifically
	 *	for this element.
	 *
	 *	@param	string	The absolute or relative URL of the source image file for the tag. The value of the source attribute.
	 *	@param	string	The value of the alt atribute of the image tag.
	 *	@param	integer	The value of the height attribute of this image pOHA object.
	 *	@param	integer	The value of the width attribute of this image pOHA object.
	 *	@param	string	The value of the class attribute to assign to this image pOHA object.
	 *	@param	string	The value of the id attribute to assign to this image pOHA object.
	 *	@access	public
	 */
	function HTMLImage($source, $alt = ' ', $height = '', $width = '', $class = '', $id = '') {
		$attributes = array	(	'src' 	=> $source,
								'alt' 	=> $alt,
								'height' => $height,
								'width' => $width,
								'class' => $class,
								'id' 	=> $id
							);
		
		parent::Element('img', $attributes);
	}
}


/**
 *	A {@link Element pOHA object} that represents a HTML comment.
 *
 *	This class is a specialised pOHA object that renders the <!-- and --!> tags
 *	that encapsulate comments within a HTML document.
 *
 *	@version 1
 *	@author Alexander R B Whillas BSCS <dev@tsd.net.au>
 *	@package pOHA
 */
class HTMLComment extends Element
{
	/**
	 *	Default constructor.
	 *
	 *	This constructor calls upon the parent constructor to set up the basic pOHA object settings specifically
	 *	for this element.
	 *
	 *	@param string $comment The text of the comment to be rendered.
	 *	@access public
	 */
	function HTMLComment($comment)
	{
		parent::Element('!--', $comment);
	}
}


/**
 *	A {@link Element pOHA object} that represents a HTML list item.
 *
 *	This class is used to create items for {@link HTMLList HTML lists}.
 *
 *	@version 1
 *	@author Alexander R B Whillas BSCS <dev@tsd.net.au>
 *	@package pOHA
 */
class HTMLListItem extends Element
{
	/**
	 *	Default constructor.
	 *
	 *	@param mixed $items An array of the list items to be rendered for this list. An element in this
	 *		array can be either a text (plain or HTML) or a {@link HTMLListItem list item pOHA object}.
	 *	@param integer $listType The type of list to render. This can be either {@link POHA_ORDERED_LIST} or
	 *		{@link POHA_UNORDERED_LIST}.
	 *	@param string $class The value of the class attribute to assign to this image pOHA object.
	 *	@param string $id The value of the id attribute to assign to this image pOHA object.
	 *		rendered as a span.
	 *	@access public
	 */
	function HTMLListItem($content, $class = '', $id = '')
	{
		$attributes = array('class' => $class, 'id' => $id);
		parent::Element('li', $attributes, $content);
	}
}


/**
 *	A {@link Element pOHA object} that represents a HTML list.
 *
 *	This class renders ordered or unordered HTML lists.
 *
 *	@version 1
 *	@author Alexander R B Whillas BSCS <dev@tsd.net.au>
 *	@package pOHA
 */
class HTMLList extends Element
{
	/**
	 *	Default constructor.
	 *
	 *	This constructor creates <li> pOHA objects for the list contents.
	 *	These are then added to a pOHA object for the list itself. This is then encapsulated in
	 *	a span which is created by a call to the parent constructor, since this is the outermost tag.
	 *
	 *	@param	mixed	An array of the list items to be rendered for this list. An element in this array can be either a text (plain or HTML) or a {@link HTMLListItem list item pOHA object}.
	 *	@param	integer	The type of list to render. This can be either {@link POHA_ORDERED_LIST} or {@link POHA_UNORDERED_LIST}.
	 *	@param	string	The value of the class attribute to assign to this image pOHA object.
	 *	@param	string	The value of the id attribute to assign to this image pOHA object. rendered as a span.
	 *	@access	public
	 */
	function HTMLList($items, $list_type = POHA_UNORDERED_LIST, $class = '', $id = '')
	{
		$attributes = array('class' => $class, 'id' => $id);
		
		if(!is_array($items))
			$content = array($items);
		else
			$content = $items;
		
		if($list_type == POHA_UNORDERED_LIST)
			$tag = 'ul';
		else 
			$tag = 'ol';
		
		foreach($content as $list_item)
			if(!is_a($list_item, 'HTMLListItem'))
				$out[] = new HTMLListItem($list_item);
		
		parent::Element($tag, $attributes, $out);
	}
}


/**
 *	A {@link Element pOHA object} that represents a HTML table cell.
 *
 *	@version 1
 *	@author Bernard Leckning <bernard@dorja.com>
 *	@package pOHA
 */
class HTMLTableCell extends Element
{
	/**
	 *	Default constructor.
	 *
	 *	@param mixed $content The content to be rendered between the tags.
	 *		This argument can be either text (plain or HTML), a {@link Element pOHA object},
	 *		an array of text and/or {@link Element pOHA objects} or nothing.
	 *	@param integer $rowspan Determines how many rows in the table this header cell will span.
	 *	@param integer $colspan Determines how many columns in the table this header cell will span.
	 *	@param string $class The value of the class attribute to assign to this pOHA object.
	 *	@param string $id The value of the id attribute to assign to this pOHA object.
	 *	@param boolean $isHeader If TRUE, then this cell is rendered as a <TH> and if FALSE it is rendered as a <TD>.
	 *	@access public
	 */
	function HTMLTableCell($content, $rowspan = 0, $colspan = 0, $class = '', $id = '', $is_header = FALSE)
	{
		if(!is_array($content))
			$content = array($content);
		
		$attributes = array('rowspan' => $rowspan, 'colspan' => $colspan, 'class' => $class, 'id' => $id);
		
		if($is_header)
			$tag = 'th';
		else
			$tag = 'td';
		
		parent::Element($tag, $attributes, $content);
	}
}


/**
 *	A {@link Element pOHA object} that represents a HTML table header cell.
 *
 *	@version 1
 *	@author Bernard Leckning <bernard@dorja.com>
 *	@package pOHA
 */
class HTMLTableHeaderCell extends HTMLTableCell
{
	/**
	 *	Default constructor.
	 *
	 *	This constructor simply delegates it's construction to it's {@link HTMLTableCell parent}
	 *	while making sure that it is rendered as a header.
	 *
	 *	@param mixed $content The content to be rendered between the tags.
	 *		This argument can be either text (plain or HTML), a {@link Element pOHA object},
	 *		an array of text and/or {@link Element pOHA objects} or nothing.
	 *	@param integer $rowspan Determines how many rows in the table this header cell will span.
	 *	@param integer $colspan Determines how many columns in the table this header cell will span.
	 *	@param string $class The value of the class attribute to assign to this pOHA object.
	 *	@param string $id The value of the id attribute to assign to this pOHA object.
	 *	@access public
	 */
	function HTMLTableHeaderCell($content, $rowspan = 0, $colspan = 0, $class = '', $id = '')
	{
		parent::HTMLTableCell($content, $rowspan, $colspan, $class, $id, TRUE);
	}
}


/**
 *	A {@link Element pOHA object} that represents a HTML table row.
 *
 *	This class is a container that manages {@link HTMLTableCell table cells} that make up
 *	the row in the {@link HTMLTable table} to which it belongs.
 *
 *	@version 1
 *	@author Bernard Leckning <bernard@dorja.com>
 *	@package pOHA
 */
class HTMLTableRow extends Element
{
	/**
	 *	Default constructor.
	 *
	 *	This constructor makes sure that all it's contents are {@link HTMLTableCell cells}.
	 *	If they are not, then they are wrapped up in a {@link HTMLTableCell}.
	 *
	 *	@param mixed $content The content to be rendered between the tags.
	 *		This argument can be either text (plain or HTML), a {@link Element pOHA object},
	 *		an array of text and/or {@link Element pOHA objects} or nothing. It expects
	 *	an array of {@link HTMLTableCell}s.
	 *	@param string $class The value of the class attribute to assign to this pOHA object.
	 *	@param string $id The value of the id attribute to assign to this pOHA object.
	 *	@access public
	 */
	function HTMLTableRow($cells, $class = '', $id = '')
	{
		$content = $this->_validateCells($cells);
		$attributes = array('class' => $class, 'id' => $id);
		parent::Element('tr', $attributes, $content);
	}
	
	/**
	 *	Returns a validated array of {@link HTMLTableCell}s to be rendered in this row.
	 *
	 *	This function checks every element in its argument to make sure that it is a {@link HTMLTableCell
	 *	table cell}. If not, the element is wrapped up in a {@link HTMLTableCell}.
	 *
	 *	@param array $cells The array of cells for this row.
	 *	@return array A validated array of {@link HTMLTableCell}s.
	 *	@access protected
	 */
	function _validateCells($cells) {
		if(is_a($cells, 'htmltablecell'))
			return array($cells);
		
		if(is_array($cells)) {
			for($i = 0; $i < sizeof($cells); $i++)
			{
				if(!is_a($cells[$i], 'htmltablecell'))
					$cells[$i] = new HTMLTableCell($cells[$i]);
			}
			
			return $cells;
		}
		
		if(is_string($cells))
			return array(new HTMLTableCell($content));
		
		return array();
	}
}


/**
 *	A {@link Element pOHA object} that represents the caption for a {@link HTMLTable HTML table}.
 *
 *	@version 1
 *	@author Bernard Leckning <bernard@dorja.com>
 *	@package pOHA
 */
class HTMLTableCaption extends Element
{
	/**
	 *	Default constructor.
	 *
	 *	@param mixed $content The content to be rendered between the tags.
	 *		This argument can be either text (plain or HTML), a {@link Element pOHA object},
	 *		an array of text and/or {@link Element pOHA objects} or nothing.
	 *	@param string $class The value of the class attribute to assign to this pOHA object.
	 *	@param string $id The value of the id attribute to assign to this pOHA object.
	 *	@access public
	 */
	function HTMLTableCaption($content, $class = '', $id = '')
	{
		$attributes = array('class' => $class, 'id' => $id);
		parent::Element('caption', $attributes, $content);
	}
}


/**
 *	A {@link Element pOHA object} that represents HTML table.
 *
 *	This class is a container of {@link HTMLTableRow rows} that display the table contents
 *	in {@link HTMLTableCell cells}.
 *
 *	@version 1
 *	@author Bernard Leckning <bernard@dorja.com>
 *	@package pOHA
 */
class HTMLTable extends Element
{
	/**
	 *	Default constructor.
	 *
	 *	This constructor performs some validation to make sure that the contents it receives
	 *	are in fact {@link HTMLTableRow}s. It also makes sure that it receives a {@link HTMLTableCaption}
	 *	as its caption.
	 *
	 *	@param mixed $rows The content to be rendered between the tags.
	 *		This argument can be either text (plain or HTML), a {@link Element pOHA object},
	 *		an array of text and/or {@link Element pOHA objects} or nothing. It expects an array of {@link
	 *		HTMLTableRow}s.
	 *	@param mixed $caption The caption of the table. This argument can be either text (plain or HTML),
	 *		a {@link Element pOHA object}, an array of text and/or {@link Element pOHA objects} or nothing.
	 *		It expects a {@link HTMLTableCaption}.
	 *	@param string $frame The value of the frame attribute for this table.
	 *	@param string $rules The value of the rules attribute for this table.
	 *	@param string $cellspacing The value of the cellspacing attribute for this table.
	 *	@param string $cellpadding The value of the cellpadding attribute for this table.
	 *	@param string $class The value of the class attribute to assign to this pOHA object.
	 *	@param string $id The value of the id attribute to assign to this pOHA object.
	 *	@access public
	 */
	function HTMLTable($rows, $caption = '', $frame = '', $rules = '',
                           $cellspacing = '', $cellpadding = '', $class = '', $id = '')
	{
		$content = $this->_validateRows($rows);
		
		if(!empty($caption))
		{
			if(is_a($caption, 'htmltablecaption'))
				$content[] = $caption;
			elseif(is_string($caption))
				$content[] = new HTMLTableCaption($caption);
		}
		
		$attributes = array('frame' => $frame,
                                    'rules' => $rules,
                                    'cellspacing' => $cellspacing,
                                    'cellpadding' => $cellpadding,
                                    'class' => $class,
                                    'id' => $id);
		
		parent::Element('table', $attributes, $content);
	}
	
	/**
	 *	Returns a validated array of {@link HTMLTableRow}s to be rendered in this table.
	 *
	 *	This function checks every element in its argument to make sure that it is a {@link HTMLTableRow
	 *	table row}. If not, the element is wrapped up in a {@link HTMLTableRow}.
	 *
	 *	@param array $rows The array of rows for this table.
	 *	@return array A validated array of {@link HTMLTableRow}s.
	 *	@access protected
	 */
	function _validateRows($rows)
	{
		if(is_a($rows, 'htmltablerow'))
			return array($rows);
		
		if(is_array($rows))
		{
			for($i = 0; $i < sizeof($rows); $i++)
			{
				if(!is_a($rows[$i], 'htmltablerow'))
					unset($rows[$i]);
			}
			
			return $rows;
		}
		
		return array();
	}
}


/**
 *	A {@link Element pOHA object} that represents a HTML based web form.
 *
 *	This class is a very flexible pOHA object for creating a web form programmatically.
 *	It is capable of accepting any type of pOHA object or plain/HTML text as content to
 *	be rendered within the <form></form> tags.
 *
 *	@version 1
 *	@author Alexander R B Whillas BSCS <dev@tsd.net.au>
 *	@package pOHA
 */
class HTMLForm extends Element
{
	/**
	 *	Default constructor.
	 *
	 *	This constructor creates <li> pOHA objects for the list contents.
	 *	These are then added to a pOHA object for the list itself. This is then encapsulated in
	 *	a span which is created by a call to the parent constructor, since this is the outermost tag.
	 *
	 *	@param mixed $content The content to be rendered between the <form></form> tags.
	 *		This argument can be either text (plain or HTML), a {@link Element pOHA object},
	 *		an array of text and/or {@link Element pOHA objects} or nothing. It should contain
	 *		pOHA objects that render form input fields.
	 *	@param string $action The value of the action attribute for this form pOHA object.
	 *	@param string $method The value of the method attribute for this form pOHA object.
	 *	@param string $encryptionType A short-hand for the value of the enctype attribute for this form
	 *		pOHA object. This argument can take on the values "application", "multipart", or "text".
	 *	@param string $class The value of the class attribute to assign to this image pOHA object.
	 *	@param string $id The value of the id attribute to assign to this image pOHA object.
	 *		rendered as a span.
	 *	@access public
	 */
	function HTMLForm	(	$content,
							$action,
							$method = 'post',
							$encription_type = 'application',
							$class = '',
							$id = ''
						)
	{
		$encryption_types = array	(	'application'	=> 'application/x-www-form-urlencoded',
										'multipart'		=> 'multipart/form-data',
										'text'			=> 'text/plain'
									);
		
		$attributes = array	(	'action'	=> $action,
								'method' 	=> $method,
								'enctype'	=> $encryption_types[$encryption_type],
								'class' 	=> $class,
								'id' 		=> $id,
								'name' 		=> $id
							);
		
		parent::Element('form', $attributes, $content);
	}
	
	/**
	 *	Redefines the {@link Element::render()} function to add content checking.
	 *
	 *	This redefinition adds a call to {@link _checkEncType()} to make sure that the encryption
	 *	type atttribute for this {@link WebForm form pOHA object} is correct.
	 *
	 *	@param integer $standard The standard to which the rendering of this {@link Element
	 *		pOHA object} is to conform to.
	 *	@param integer $tabLevel The level of indentation at which this {@link WebForm form pOHA object} is to
	 *		be rendered.
	 *	@return string The generated HTML.
	 *	@access public
	 */
	function render($standard = POHA_HTML_4, $tab_level = 0)
	{
		$this->_checkEncType($this->_content);
		return parent::render($standard, $tab_level);
	}
	
	/**
	 *	Checks to make sure that the enctype attribute for this {@link WebForm form pOHA object}
	 *	is valid for the contents of the form.
	 *
	 *	This method simply checks for the existence of a {@link InputFile file input pOHA object} and changes the
	 *	form pOHA object's enctype attribute to "multipart/form-data".
	 *
	 *	@param mixed $content The content to be rendered between the <form></form> tags.
	 *		This argument can be either text (plain or HTML), a {@link Element pOHA object},
	 *		an array of text and/or {@link Element pOHA objects} or nothing. It should contain
	 *		pOHA objects that render form input fields.
	 *	@return boolean TRUE if the enctype attribute had to be changed and FALSE otherwise.
	 *	@access protected
	 */
	function _checkEncType($content)
	{
		if(!empty($content))
		{
			foreach($content as $item)
			{
				if(!empty($item))
					if(is_object($item) and is_subclass_of($item, 'Element'))
					{
						if(is_a($item, 'HTMLInputFile'))
						{
							$this->_attributes['enctype'] = 'multipart/form-data';
							return true;
						}
						else
						{
							if(!empty($item->_content))
							{
								if($this->_checkEncType($item->_content))
									break;
							}
						}
					}
					elseif(is_array($item))
						if($this->_checkEncType($item))
							break;
			}
			
			return false;
		}
	}
}

/**
 *	A {@link Element pOHA object} that generically represents a HTML form input field.
 *
 *	@version 1
 *	@author Alexander R B Whillas BSCS <dev@tsd.net.au>
 *	@package pOHA
 */
class HTMLInput extends Element
{
	/**
	 *	Default constructor.
	 *
	 *	@param	string	The type of input field to render. This can be any one of the valid HTML input types.
	 *	@param	string	The value of the name attribute of this input field.
	 *	@param	string	The value of this input field.
	 *	@param	string	The value of the class attribute to assign to this image pOHA object.
	 *	@param	string	The value of the id attribute to assign to this image pOHA object.
	 *	@access	public
	 */
	function HTMLInput($type, $name, $value, $class = '', $id = '')
	{
		parent::Element('input', array	(	'name'	=> $name,
											'type'	=> $type,
											'value'	=> $value,
											'class'	=> $class,
											'id'	=> $id
										));
	}
}

/**
 *	A {@link Element pOHA object} that represents a HTML form text input field.
 *
 *	This class is a specialised version of {@link HTMLInput}.
 *
 *	@version 1
 *	@author Bernard Leckning <bernard@dorja.com>
 *	@package pOHA
 */
class HTMLInputText extends HTMLInput
{
	/**
	 *	Default constructor.
	 *
	 *	@param string $name The value of the name attribute of this input field.
	 *	@param string $value The value of this input field.
	 *	@param string $class The value of the class attribute to assign to this image pOHA object.
	 *	@param string $id The value of the id attribute to assign to this image pOHA object.
	 *	@access public
	 */
	function HTMLInputText($name, $value, $class = '', $id = '')
	{
		parent::HTMLInput('text', $name, $value, $class, $id);
	}
}


/**
 *	A {@link Element pOHA object} that represents a HTML form textarea input field.
 *
 *	@version 1
 *	@author Bernard Leckning <bernard@dorja.com>
 *	@package pOHA
 */
class HTMLInputTextArea extends Element
{
	/**
	 *	The value of this textarea form input field.
	 *
	 *	This value is what is displayed as the contents of the textarea.
	 *
	 *	@var string $_value
	 *	@access protected
	 */
	var $_value;
	
	/**
	 *	Default constructor.
	 *
	 *	@param string $name The value of the name attribute of this input field.
	 *	@param string $value The value of this input field.
	 *	@param integer $rows The height of this textarea as a number of rows.
	 *	@param integer $columns The width of this textarea as a number of columns.
	 *	@param string $wrap The type of word-wrapping to perform with the contents of this textarea.
	 *	@param string $class The value of the class attribute to assign to this pOHA object.
	 *	@param string $id The value of the id attribute to assign to this pOHA object.
	 *	@access public
	 */
	function HTMLInputTextArea	(	$name,
									$value = '',
									$rows = 5,
									$columns = 30,
									$wrap = 'soft',
									$class = '',
									$id = ''
								)
	{
		$attributes = array	(	'name'	=> $name,
								'wrap'	=> $wrap,
								'rows'	=> $rows,
								'cols'	=> $columns,
								'class'	=> $class,
								'id'	=> $id
							);
		parent::Element('textarea', $attributes, NULL);
		
		$this->_no_white_space = TRUE;
		$this->_tag_type = POHA_BLOCK;
		
		$this->_value = $value;
	}
	
	/**
	 *	Properly renders this textarea and it's contents.
	 *
	 *	This redefinition is required due to the formatting is carried out by the {@link Element::render()
	 *	default rendering function}. This function ensures no whitespaces are included in the contents of the textarea.
	 *
	 *	@param integer $standard The standard to which the rendering of this pOHA object is to conform to.
	 *	@param integer $tabLevel The level of indentation at which this is to be rendered.
	 *	@return string The generated HTML.
	 *	@access public
	 */
	function render($standard = POHA_HTML_4, $tab_level = 0)
	{
		$tab = str_repeat("\t", $tab_level);
		
		$output = $tab.'<'.$this->_tag.' '.$this->_renderAttributes($this->_attributes).">";
		$output .= $this->_value.'</'.$this->_tag.">\n";
		
		return $output;
	}
}


/**
 *	A {@link Element pOHA object} that represents a HTML form password input field.
 *
 *	@version 1
 *	@author Bernard Leckning <bernard@dorja.com>
 *	@package pOHA
 */
class HTMLInputPassword extends HTMLInput
{
	/**
	 *	Default constructor.
	 *
	 *	@param string $name The value of the name attribute of this input field.
	 *	@param string $value The value of this input field.
	 *	@param string $class The value of the class attribute to assign to this pOHA object.
	 *	`@param string $id The value of the id attribute to assign to this pOHA object.
	 *	@access public
	 */
	function HTMLInputPassword($name, $value = '', $class = '', $id = '')
	{
		parent::HTMLInput('password', $name, $value, $class, $id);
	}
}


/**
 *	A {@link Element pOHA object} that represents a HTML hidden input field.
 *
 *	@version 1
 *	@author Bernard Leckning <bernard@dorja.com>
 *	@package pOHA
 */
class HTMLInputHidden extends HTMLInput
{
	/**
	 *	Default constructor.
	 *
	 *	@param string $name The value of the name attribute of this input field.
	 *	@param string $value The value of this input field.
	 *	@param string $id The value of the id attribute to assign to this pOHA object.
	 *	@access public
	 */
	function HTMLInputHidden($name, $value, $id = '')
	{
		parent::HTMLInput('hidden', $name, $value, '', $id);
	}
}


/**
 * @version	1.0
 * @author	Alexander R B Whillas <dev@tsd.net.au>
 * @package	pOHA
 * @see		HTMLInputRadio
 */
class HTMLInputRadio extends HTMLInput
{
	var $_checked;
	
	function HTMLInputRadio($name, $value, $class = '', $id = '', $checked = FALSE)
	{
		parent::HTMLInput('radio', $name, $value, $class, $id);
		$this->_checked = $checked;
	}
	
	function render($standard = POHA_HTML_4, $tab_level = 0) {
		$tab = str_repeat("\t", $tab_level);
		
		$s = '';
		if($this->checked)
			$s = ' checked';
		return $tab.'<'.$this->_tag.' '.$this->_renderAttributes($this->_attributes).$s." />\n";
	}
}


/**
 * A {@link Element pOHA object} that represents a group of radio
 * buttons for one field value.
 *
 * @version	1.0
 * @author	Alexander R B Whillas <dev@tsd.net.au>
 * @package	pOHA
 * @see		HTMLInputRadio
 */
class HTMLInputRadioGroup extends Element
{
	/**
	 * Default constructor.
	 *
	 * @param	string	Name of the field.
	 * @param	string	The label for this radio button group.
	 * @param 	array	An associative array of options in the format: array('value' => 'caption')
	 * @param	string	The value of the class attribute to assign to this group of pOHA objects.
	 * @param	string	The value of the id attribute to assign to this group of pOHA objects.
	 * @access	public
	 */
	function HTMLInputRadioGroup($name, $label, $options, $selected = '', $class = '', $id = '')
	{
            if(!is_array($options))
            {
                    $options = array($options);
            }

            $r = "";//array();

            $leg = "<legend>$label</legend><br/>";

            foreach($options as $value => $caption)
            {
                if ($value == $selected)
                {
                    $checked = TRUE;
                }
                else
                {
                    $checked = FALSE;
                }

                $ir = new HTMLInputRadio($name, $value, 'radioinput', '', $checked);
                $r .= $ir->render()." $caption<br/>";
            }
            
            parent::Element('fieldset', array('class' => $class, 'id' => $id), $leg.$r);
	}
}


/**
 * A {@link Element pOHA object} that represents checkbox input control.
 *
 * @version	1.0
 * @author	Alexander R B Whillas <dev@tsd.net.au>
 * @package	pOHA
 * @see		HTMLInputRadio
 */
class HTMLInputCheckbox extends HTMLInput
{
	var $_checked;
	
	function HTMLInputCheckbox($name, $value, $class = '', $id = '', $checked = FALSE)
	{
		parent::HTMLInput('checkbox', $name, $value, $class, $id);
		$this->_checked = $checked;
	}
	
	function render($standard = POHA_HTML_4, $tabLevel = 0)
	{
		$tab = str_repeat("\t", $tab_level);
		
		$s = '';
		if($this->checked)
			$s = ' checked';
		return $tab.'<'.$this->_tag.' '.$this->_renderAttributes($this->_attributes).$s." />\n";
	}
}


/**
 *	A {@link Element pOHA object} that represents a HTML option.
 *
 *	HTML options are used in {@link HTMLInputSelect HTML form select input fields}.
 *	They represent individual elements in HTML form select input fields.
 *
 *	@version 1
 *	@author Bernard Leckning <bernard@dorja.com>
 *	@package pOHA
 */
class HTMLInputOption extends Element
{
	var $_value;
	var $_caption;
	var $_selected;
	
	/**
	 *	Default constructor.
	 *
	 *	If a caption is not supplied, then this constructor assigns the name attribute
	 *	as it's caption.
	 *
	 *	@param string $value The value of this input field.
	 *	@param string $caption The display text for this option.
	 *	@param boolean $selected Determines whether or not this option will be selected in the HTML form select input field.
	 *	@param string $class The value of the class attribute to assign to this pOHA object.
	 *	@access public
	 */
	function HTMLInputOption($value, $caption = '', $selected = 0, $class = '')
	{
		$this->_value = $value;
		$this->_caption = empty($caption) ? $value : $caption;
		$this->_selected = $selected;
		parent::Element('option', array('value' => $value, 'class' => $class), NULL);
	}
	
	/**
	 *	Properly renders this opion and it's contents.
	 *
	 *	This redefinition is required due to the fact that the selected attribute is not an XML
	 *	standard attribute and cannot be handled properly by {@link Element::render()}.
	 *
	 *	@param integer $standard The standard to which the rendering of this pOHA object is to conform to.
	 *	@param integer $tabLevel The level of indentation at which this is to be rendered.
	 *	@return string The generated HTML.
	 *	@access public
	 */
	function render($standard = POHA_HTML_4, $tab_level = 0)
	{
            $s = "";
            $tab = str_repeat("\t", $tab_level);

            //TODO: Fix "Selected"
            /*
            echo "-> \"".$this->_selected."<br>";

            if($this->_selected)
            {
                $s .= " selected='selected'";
            }
            */

            $output = $tab.'<'.$this->_tag.' '.$this->_renderAttributes($this->_attributes).' '.$s.'>';
            $output .= $this->_caption.'</'.$this->_tag.">\n";
            return $output;
	}
}


/**
 *	A {@link Element pOHA object} that represents a HTML option group.
 *
 *	@version 1
 *	@author Bernard Leckning <bernard@dorja.com>
 *	@package pOHA
 */
class HTMLInputOptionGroup extends Element
{
	/**
	 *	Default constructor.
	 *
	 *	If any of the supplied options are not {@link HTMLInputOption}s then they are wrapped in
	 *	{@link HTMLInputOption}s by this constructor.
	 *
	 *	@param string $label The label for this option group.
	 *	@param mixed $content The content to be rendered between the <form></form> tags.
	 *		This argument can be either text (plain or HTML), a {@link Element pOHA object},
	 *		an array of text and/or {@link Element pOHA objects} or nothing. It should contain
	 *		pOHA objects that render form input fields. It expects an array of {@link HTMLInputOption}s.
	 *	@param string $class The value of the class attribute to assign to this pOHA object.
	 *	@param string $id The value of the id attribute to assign to this pOHA object.
	 *	@access public
	 */
	function HTMLInputOptionGroup($label, $options, $class = '', $id = '')
	{
		if(!is_array($options))
			$options = array($options);
		
		$o = array();
		foreach ($options as $value => $item)
		{
			if(is_a($item, 'HTMLInputOption'))
				$o[] = $item;
			else
				$o[] = new HTMLInputOption($value, $item);
		}
		
		parent::Element('optgroup', array('label' => $label, 'class' => $class, 'id' => $id), $o);
	}
}



/**
 *	A {@link Element pOHA object} that generically represents a HTML form select input.
 *
 *	This generic version allows it to be constructed either as a drop-down, single-select or
 *	multi-select listbox.
 *
 *	@version 1
 *	@author Bernard Leckning <bernard@dorja.com>
 *	@package pOHA
 */
class HTMLInputSelect extends Element
{
	/**
	 *	Indicates whether or not this form select input field is rendered as a multi-select listbox.
	 *
	 *	@var boolean $_multiple
	 *	@access protected
	 */
	var $_multiple;
	
	/**
	 *	Default constructor.
	 *
	 *	If any of the supplied options are not {@link HTMLInputOption}s or {@link HTMLInputOptionGroup}s
	 *	then they are wrapped in {@link HTMLInputOption}s by this constructor. This constructor
	 *	also sets the {@link HTMLInputOption::selected} flag for any HTML options whose value matches
	 *	the supplied selected value.
	 *
	 *	@param string $name The value of the name attribute for this form select input field.
	 *	@param mixed $options The options of this form select input field.
	 *		This argument can be either text (plain or HTML), a {@link Element pOHA object},
	 *		an array of text and/or {@link Element pOHA objects} or nothing. It expects an array of
	 *	{@link HTMLInputOption}s and/or {@link HTMLInputOptionGroup}s.
	 *	@param boolean $multiple Determines whether or not multiple options can be selected.
	 *	@param string $class The value of the class attribute to assign to this pOHA object.
	 *	@param string $id The value of the id attribute to assign to this pOHA object.
	 *	@access public
	 */
	function HTMLInputSelect($name, $options, $selectedValue = '',
                                 $multiple = FALSE, $class = '', $id = '')
	{
		$this->_multiple = $multiple;
		$attributes = array('name' => $name, 'class' => $class, 'id' => $id);
		
		if(!is_array($options))
                {
                    $options = array($options);
                }
		
		$o = array();
                
		foreach ($options as $value => $item)
		{
                    if(is_a($item, 'HTMLInputOption'))
                    {
                        $item->_selected = $item->_value == $selectedValue;
                        $o[] = $item;
                    }
                    elseif(is_a($item, 'HTMLInputOptionGroup'))
                    {
                        for($i = 0; $i < sizeof($item->_content); $i++)
                        {
                            $item->_content[$i]->selected = $item->_content[$i]->value == $selectedValue;
                        }
                    }
                    else
                    {
                        $o[] = new HTMLInputOption($value, $item, $value == $selectedValue);
                    }
		}
		
		parent::Element('select', $attributes, $o);
	}
	
	/**
	 *	Properly renders this form select list input and it's options.
	 *
	 *	This redefinition is required due to the fact that the multiple attribute is not an XML
	 *	standard attribute and cannot be handled properly by {@link Element::render()}.
	 *
	 *	@param integer $standard The standard to which the rendering of this pOHA object is to conform to.
	 *	@param integer $tabLevel The level of indentation at which this is to be rendered.
	 *	@return string The generated HTML.
	 *	@access public
	 */
	function render($standard = POHA_HTML_4, $tab_level = 0)
	{
		$tab = str_repeat("\t", $tab_level);
		
		$s = $this->_multiple ? ' multiple' : '';
		$output = $tab.'<'.$this->_tag.' '.$this->_renderAttributes($this->_attributes).$s.">\n";
		$output .= $this->_processContent($this->_content, $standard, $tabLevel++);
		$output .= $tab.'</'.$this->_tag.">\n";
		
		return $output;
	}
}


/**
 *	A {@link Element pOHA object} that represents a HTML form drop-down input field.
 *
 *	This class is a specialised version of {@link HTMLInputSelect}.
 *
 *	@version 1
 *	@author Bernard Leckning <bernard@dorja.com>
 *	@package pOHA
 */
class HTMLInputDropDown extends HTMLInputSelect
{
	/**
	 *	Default constructor.
	 *
	 *	This constructor delegates to the {@link HTMLInputSelect::HTMLInputSelect() parent constructor}
	 *	ensuring that the form select list input field is rendered as a drop-down.
	 *
	 *	@param string $name The value of the name attribute for this form select input field.
	 *	@param mixed $options The options of this form select input field.
	 *		This argument can be either text (plain or HTML), a {@link Element pOHA object},
	 *		an array of text and/or {@link Element pOHA objects} or nothing. It expects an array of
	 *	{@link HTMLInputOption}s and/or {@link HTMLInputOptionGroup}s.
	 *	@param string $class The value of the class attribute to assign to this pOHA object.
	 *	@param string $id The value of the id attribute to assign to this pOHA object.
	 *	@access public
	 */
	function HTMLInputDropDown($name, $options, $selected_value = '', $class = '', $id = '')
	{
		parent::HTMLInputSelect($name, $options, $selected_value, FALSE, $class, $id);
	}
}


/**
 *	A {@link Element pOHA object} that represents a HTML form listbox input field.
 *
 *	This class is a specialised version of {@link HTMLInputSelect}.
 *
 *	@version 1
 *	@author Bernard Leckning <bernard@dorja.com>
 *	@package pOHA
 */
class HTMLInputListBox extends HTMLInputSelect
{
	/**
	 *	Default constructor.
	 *
	 *	This constructor delegates to the {@link HTMLInputSelect::HTMLInputSelect() parent constructor}
	 *	ensuring that the form select list input field is rendered as a listbox.
	 *
	 *	@param string $name The value of the name attribute for this form select input field.
	 *	@param mixed $options The options of this form select input field.
	 *		This argument can be either text (plain or HTML), a {@link Element pOHA object},
	 *		an array of text and/or {@link Element pOHA objects} or nothing. It expects an array of
	 *	{@link HTMLInputOption}s and/or {@link HTMLInputOptionGroup}s.
	 *	@param string $class The value of the class attribute to assign to this pOHA object.
	 *	@param string $id The value of the id attribute to assign to this pOHA object.
	 *	@access public
	 */
	function HTMLInputListBox($name, $options, $selected_value, $class = '', $id = '')
	{
		parent::HTMLInputSelect($name, $options, $selected_value, TRUE, $class, $id);
	}
}


/**
 *	A {@link Element pOHA object} that represents a HTML form file input field.
 *
 *	This class renders a HTML form input field for uploading files to the web server.
 *
 *	@version 1
 *	@author Bernard Leckning <bernard@dorja.com>
 *	@package pOHA
 */
class HTMLInputFile extends HTMLInput
{
	/**
	 *	Default constructor.
	 *
	 *	@param string $name The value of the name attribute for this form button input.
	 *	@param mixed $value The value of this form button input.
	 *	@param mixed $accept The mime types that this form file input field will ask the user agent to accept.
	 *		This argument can be an array of strings which represent the mime types to accept or one of
	 *		the pOHA preconfigured mime type groups.
	 *	@param string $class The value of the class attribute to assign to this pOHA object.
	 *	@param string $id The value of the id attribute to assign to this pOHA object.
	 *	@access public
	 */
	function HTMLInputFile($name,  $value = '', $accept = '', $class = '', $id = '')
	{
		if(!is_array($accept))
		{
			switch($accept)
			{
				case POHA_FILE_INPUT_ACCEPT_IMAGES:
					$accept = array('image/pjpeg', 'image/jpeg', 'image/gif', 'image/png', 'image/x-png');
					break;
				case POHA_FILE_INPUT_ACCEPT_DOCUMENT:
					$accept = array('text/plain', 'text/html');
					break;
				case POHA_FILE_INPUT_ACCEPT_AUDIO:
					$accept = array('audio/basic');
					break;
				case POHA_FILE_INPUT_ACCEPT_VIDEO:
					$accept = array('video/mpeg');
					break;
				default:
					$accept = '';
			}
		}
		
		if(is_array($accept))
			$accept = implode($accept, ', ');
		
		parent::HTMLInput('file', $name, $value, $class, $id);
		$this->_attributes['accept'] = $accept;
	}
}


/**
 *	A {@link Element pOHA object} that generically represents a HTML button.
 *
 *	This button is able to show mixed content on the button face.
 *
 *	@version 1
 *	@author Bernard Leckning <bernard@dorja.com>
 *	@package pOHA
 */
class HTMLInputButton extends Element
{
	/**
	 *	Default constructor.
	 *
	 *	@param mixed $content The content to be rendered on the button face.
	 *		This argument can be either text (plain or HTML), a {@link Element pOHA object},
	 *		an array of text and/or {@link Element pOHA objects} or nothing.
	 *	@param string $name The value of the name attribute for this form button input.
	 *	@param mixed $value The value of this form button input.
	 *	@param string $type The type of button to render. This can be 'button', 'submit' or 'reset'.
	 *	@param string $class The value of the class attribute to assign to this pOHA object.
	 *	@param string $id The value of the id attribute to assign to this pOHA object.
	 *	@access public
	 */
	function HTMLInputButton($name, $value, $content = NULL, $type = 'button', $class = '', $id = '')
	{
		switch($type)
		{
			case 'button':
			case 'submit':
			case 'reset':
				break;
			case 'default':
				$type = 'button';
				break;
		}
		
		if(empty($value))
			$value = $name;
		
		if(is_null($content))
			$content = $name;
			
		parent::Element	(	'button',
							array(	'name' 	=> $name,
									'value' => $value,
									'type' 	=> $type,
									'class' => $class,
									'id' 	=> $id
								),
							$content
						);
	}
	
	function render($standard = POHA_HTML_4, $tab_level = 0)
	{
		if ($standard == POHA_HTML_3_2)
		{
			$this->_tag_type = POHA_INLINE;
			$this->_tag = 'input';
		}
		else
			$this->_tag_type = POHA_BLOCK;
			
		return parent::render($standard, $tab_level);
	}
}


/**
 *	A {@link Element pOHA object} that represents a HTML submit button.
 *
 *	This button is able to show mixed content on the button face and can be used in a
 *	{@link HTMLForm HTML form} as the button that causes the submit.
 *
 *	@version 1.0
 *	@author Bernard Leckning <bernard@dorja.com>
 *	@package pOHA
 */
class HTMLInputSubmitButton extends HTMLInputButton
{
	/**
	 *	Default constructor.
	 *
	 *	@param mixed $content The content to be rendered on the button face.
	 *		This argument can be either text (plain or HTML), a {@link Element pOHA object},
	 *		an array of text and/or {@link Element pOHA objects} or nothing.
	 *	@param string $name The value of the name attribute for this form button input.
	 *	@param mixed $value The value of this form button input.
	 *	@param string $class The value of the class attribute to assign to this pOHA object.
	 *	@param string $id The value of the id attribute to assign to this pOHA object.
	 *	@access public
	 */
	function HTMLInputSubmitButton($name = '', $value = '', $content = NULL, $class = '', $id = '')
	{
		parent::HTMLInputButton($name, $value, $content, 'submit', $class, $id);
	}
}


/**
 *	A {@link Element pOHA object} that represents a HTML submit button.
 *
 *	This button is able to show mixed content on the button face and can be used in a
 *	{@link HTMLForm HTML form} as the button that causes the submit.
 *
 *	@version	1.0
 *	@author		Alexander R B Whillas BSCS <dev@tsd.net.au>
 *	@package	pOHA
 */
class HTMLInputLabel extends Element
{
	function HTMLInputLabel($content, $for, $accesskey = '', $class = '', $id = '')
	{
		parent::Element	(	'label',
							array('for' => $for, 'class' => $class, 'id' => $id),
							$content
						);
	}
}


?>